<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
	<meta charset="utf-8" />
	<title>应用菜单管理 - {$Think.lang.cfg_website}</title>
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="{$NOW_THEME_URL}/Assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/plugins/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style-metro.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="{$NOW_THEME_URL}/Assets/css/themes/{:session('skin')}.css" rel="stylesheet" type="text/css" id="style_color"/>
	<!-- END GLOBAL MANDATORY STYLES -->
	<!-- BEGIN PAGE LEVEL STYLES -->
	<!-- END PAGE LEVEL STYLES -->
	<link rel="shortcut icon" href="favicon.ico" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
	<!-- BEGIN HEADER -->
	<include file="Public:header" />
	<!-- END HEADER -->
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<!-- BEGIN SIDEBAR -->
		<div class="page-sidebar nav-collapse collapse">
			<!-- BEGIN SIDEBAR MENU -->        
			<ul class="page-sidebar-menu">
            	<li>
					<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
					<div class="sidebar-toggler hidden-phone"></div>
					<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
				</li>
                {$menu_tree}
            </ul>
			<!-- END SIDEBAR MENU -->
		</div>
		<!-- END SIDEBAR -->
		<!-- BEGIN PAGE -->
		<div class="page-content">
			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<div id="portlet-config" class="modal hide">
				<div class="modal-header">
					<button data-dismiss="modal" class="close" type="button"></button>
					<h3>portlet Settings</h3>
				</div>
				<div class="modal-body">
					<p>Here will be a configuration form</p>
				</div>
			</div>
			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<!-- BEGIN PAGE CONTAINER-->        
			<div class="container-fluid">
				<!-- BEGIN PAGE HEADER-->
				<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN PAGE TITLE & BREADCRUMB-->
						<div class="clear">&nbsp;</div>
						<ul class="breadcrumb">
							<li>
								<i class="icon-home"></i>
								<a href="__APP__/menu">{$Think.lang.cfg_page_home}</a> 
								<span class="icon-angle-right"></span>
							</li>
							<li>
								<a href="#">应用菜单管理</a> 
								<span class="icon-angle-right"></span>
						  </li>
						</ul>
						<!-- END PAGE TITLE & BREADCRUMB-->
					</div>
				</div>
				<!-- END PAGE HEADER-->
				<!-- BEGIN PAGE CONTENT-->
				<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN EXAMPLE TABLE PORTLET-->
						<div class="portlet box light-grey">
							<div class="portlet-title">
								<div class="caption"><i class="icon-reorder"></i>应用菜单列表</div>
								<div class="actions">
									<a href="__URL__/menuAdd" class="btn green">
										<i class="icon-plus"></i> {$Think.lang.cfg_list_itf_btn_add}
									</a>
								</div>
							</div>
							<div class="portlet-body flip-scroll">
								<form action="{:U('Company/menuSort')}" method="post" name="form">
								<table class="table table-striped table-bordered table-hover table-condensed flip-content" id="userList">
                                	<thead>					
                                    <tr class="list_head ct" style="text-align:center">
                                      <td width="70">{$Think.lang.cfg_form_ele_sort}</td>
                                      <td >应用菜单名称</td>
                                      <td width="120">链接</td>
                                      <td width="70">类型</td>
                                      <td width="200">管理操作</td>
                                    </tr>
                                    </thead>
									<tbody id="tree">
                                    {$html_tree}
                                    </tbody>
                                    <tfoot>
                                    <tr class="tr">
                                      <td colspan="5" valign="middle">
                                        <button type="submit" class="btn blue">
                                        	<i class="icon-sort-by-order"></i> 排序
                                        </button>
                                      </td>
                                    </tr>
                                    </tfoot>
								</table>
                                </form>
							</div>
						</div>
						<!-- END EXAMPLE TABLE PORTLET-->
					</div>
				</div>				
				<!-- END PAGE CONTENT-->
			</div>
			<!-- END PAGE CONTAINER-->
		</div>
		<!-- END PAGE -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
    <include file="Public:footer" />
	<!-- END FOOTER -->
	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script src="__PUBLIC__/Js/jquery.min.js" type="text/javascript"></script>
	<script src="{$NOW_THEME_URL}/Assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>   
	<script src="{$NOW_THEME_URL}/Assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/jquery.artdialog.js?skin=bootstrap"></script>
	<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/plugins/artdialog/plugins/iframeTools.js"></script>
	<!--[if lt IE 9]>
	<script src="{$NOW_THEME_URL}/Assets/plugins/excanvas.min.js"></script>
	<script src="{$NOW_THEME_URL}/Assets/plugins/respond.min.js"></script>  
	<![endif]-->  
	<script src="{$NOW_THEME_URL}/Assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
    
	<!-- END PAGE LEVEL PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="{$NOW_THEME_URL}/Assets/scripts/app.js"></script>
	<!-- END JAVASCRIPTS -->
    <script type="text/javascript">
		var ABS_URL_Theme = "{$NOW_THEME_URL}/";
		jQuery(document).ready(function() {   
			// initiate layout and plugins
			App.init();
			
			//删除
			$('.delAlone').live('click',function(){
				var obj = $(this);
				$.get('{$Think.const.__URL__}/menuDel/id/'+$(this).attr('data-id'),function(data){
					art.dialog.alert(data.info);
					if(data.status==1){
						obj.parents("tr").remove();
					}
				});
			});
			
			dealNode();
		});
		
		function dealNode(){
			$('#tree .level_1 .name').each(function(index, element) {
				$(this).prepend('<span class="unfold">&nbsp;</span>');
			});
			$('#tree .level_2 .name').each(function(index, element) {
				$(this).prepend('<span class="unfold" style="margin-left:30px;">&nbsp;</span>');
			});
			$('#tree .level_3 .name').each(function(index, element) {
				$(this).prepend('<span style="margin-left:47px;">&nbsp;</span>');
			});
			
			$('#tree .level_2').hide();
			$('#tree .level_3').hide();
			
			$('.name').on('click',function(){
				var parent = $(this).parent('tr');
				if(parent.is('.level_3')){
					return false;
				}
				
				var nowfold = $(this).children('span').is('.unfold');
				if(nowfold){
					$(this).children('span').addClass('fold').removeClass('unfold');
				}else{
					$(this).children('span').removeClass('fold').addClass('unfold');
				}
				
				
				if(parent.is('.level_1')){
					if(nowfold){
						parent.nextAll('tr').each(function(index, element) {
							if($(this).is('.level_1')){
								return false;
							}
							if($(this).is('.level_2')){
								$(this).show();
								$(this).children('span').removeClass('fold').addClass('unfold');
							}
						});
					}else{
						parent.nextAll('tr').each(function(index, element) {
							if($(this).is('.level_1')){
								return false;
							}
							if($(this).is('.level_2')){
								$(this).children('.name').children('span').removeClass('fold').addClass('unfold');
							}
							$(this).hide();
						});
					}					
				}
				
				if(parent.is('.level_2')){
					parent.nextAll('tr').each(function(index, element) {
						if($(this).is('.level_2')){
							return false;
						}
						if($(this).is('.level_3')){
							$(this).toggle();
						}
					});
				}
				
			});
		}
	</script>
</body>
<!-- END BODY -->
</html>